package edu.hwadee.serviceImpl;

import java.util.List;

import edu.hwadee.entity.Payfee;
import edu.hwadee.service.PayfeeService;

public class PayfeeServiceImpl extends BasicServiceImpl implements PayfeeService {

	@Override
	public boolean save(Payfee payfee) {
		try {
			getPayfeeDAO().save(payfee);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public boolean delete(Payfee payfee) {
		try {
			getPayfeeDAO().delete(payfee);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Payfee> search(Payfee payfee) {
		try {
			return (List<Payfee>)getPayfeeDAO().findByExample(payfee);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Payfee searchById(Integer payFeeId) {
		try {
			return getPayfeeDAO().findById(payFeeId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public boolean update(Payfee payfee) {
		try {
			if(searchById(payfee.getPayFeeId()) != null) {
				getPayfeeDAO().merge(payfee);
				return true;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Payfee> showAll() {
		try {
			return (List<Payfee>)getPayfeeDAO().findAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
